import { http } from "@/utils/http";
import type { ResultProps } from "@/api/user";

export interface FormulaVersionListProp {
  id: number;
  account_id: number;
  business_id: number;
  name: string;
  note: string;
  formula_count: number;
  publish_status: number;
  delete_status: number;
  update_time: Date;
  create_time: Date;
  publish_time: Date;
  device_type: string;
}

export const getFormulaVersionList = (data?: object) => {
  return http.request<ResultProps<FormulaVersionListProp[]>>(
    "get",
    "/formulaVersion/getList",
    {
      params: data
    }
  );
};

export const versionsAdd = (data?: object) => {
  return http.request<ResultProps<any[]>>("post", "/formulaVersion/add", {
    data
  });
};

export const versionsUpdate = (data?: object) => {
  return http.request<ResultProps<any[]>>("post", "/formulaVersion/upd", {
    data
  });
};

export const versionsDelete = (data?: object) => {
  return http.request<ResultProps<any[]>>("post", "/formulaVersion/del", {
    data
  });
};

export const updateStatus = (data?: object) => {
  return http.request<ResultProps<any[]>>("post", "/formulaVersion/publish", {
    data
  });
};

export const formulaVersionRelease = (data?: object) => {
  return http.request<ResultProps<any[]>>("post", "/formulaVersion/release", {
    data
  });
};

export const formulaVersionGetRelease = (data?: object) => {
  return http.request<ResultProps<any[]>>(
    "post",
    "/formulaVersion/getReleaseStoreList",
    {
      data
    }
  );
};
